<?php
session_start();

function printPage($title,$content)
	{
		return '<!DOCTYPE html>
				<html lang="en">
					<head>
						<meta charset="utf-8">
						<title>'.$title.'</title>
						'.includeHeader().'
					</head>
					<body style="padding-bottom: 20px;" onload="timedCount()">
						<div class="container">
							<div class="span3" style="margin-bottom:5px; margin-left:0px">
							</div>	
							'.includeMenu().'
						</div>
						<div class="container thumbnail">
							<div class="row-fluid">
								<div class="span12" style="height:15px">
								</div>
								'.includeProfile().'
								<div class="span9">
									'.$content.'
								</div>
							</div>
							<div class="btn disabled btn-block" style="margin-bottom: 0px;">
								<a href="http://nusakreatif.com" style="color:#000000">
									Powered by Mucliis &copy; 2013
								</a>
							</div>
						</div>
						'.includeFooter().'
					</body>
				</html>';
	}
	
function includeHeader()
	{
		return'<meta name="viewport" content="width=device-width, initial-scale=1.0">
				<meta name="description" content="">
				<meta name="author" content="">
				<!-- main styles -->
					<link rel="stylesheet" href="headmaster/css/style.css" />
				<!-- Le styles -->
				<link href="assets/css/bootstrap.css" rel="stylesheet">
				<!--
				<style type="text/css">
				  body
				   {
						padding-top: 60px;
						padding-bottom: 40px;
					}
				</style>
				-->
				<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
				<link href="assets/css/mystyle.css" rel="stylesheet">
				 <link rel="stylesheet" href="assets/jBreadcrumbs/css/BreadCrumb.css" />
				<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
				<!--[if lt IE 9]>
   			    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
				<![endif]-->
				<!-- Fav and touch icons -->
				<link rel="shortcut icon" href="assets/ico/favicon.png">
				<!--<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
				<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
				<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
				<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">-->
				<!-- colorbox -->
				<script src="assets/js/jquery.js"></script>
				<script src="jquery.colorbox.js"></script>
				<link rel="stylesheet" href="colorbox.css" />
				<link rel="stylesheet" href="treeview.css" />
				<script>
					$(document).ready(function () 
						{
							//$("#cari").hide();
							$("#jCrumbs").jBreadCrumb
								({
									endElementsToLeaveOpen: 0,
									beginingElementsToLeaveOpen: 0,
									timeExpansionAnimation: 500,
									timeCompressionAnimation: 500,
									timeInitialCollapse: 500,
									previewWidth: 30
								});
							//colorbox
							$(".show").colorbox({width:600,height:400});
						});
				</script>		

				<script type="text/javascript">
					var c=0;
					var t;

					function loadXMLDoc()
					{
						var xmlhttp;
						if (window.XMLHttpRequest)
						{// code for IE7+, Firefox, Chrome, Opera, Safari
							xmlhttp=new XMLHttpRequest();
						}
						else
						{// code for IE6, IE5
							xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
						}
						  
						xmlhttp.onreadystatechange=function()
						{
							if (xmlhttp.readyState==4 && xmlhttp.status==200)
							{
								document.getElementById("jam").innerHTML=xmlhttp.responseText;
							}
						}
						
						//proses update direquest ke file .php
						xmlhttp.open("GET","jam.php",true);
						xmlhttp.send();
					}

					function timedCount()
					{
						//proses update direfresh per 60 detik lewat ajax
						loadXMLDoc();
						t=setTimeout("timedCount()",1000);
					}

				</script>
				
				</style>
					<link rel="stylesheet" href="colorboxfile/colorbox.css" />
					<script src="colorboxfile/jquery.min.js"></script>
					<script src="colorboxfile/jquery.colorbox.js"></script>
					<script>
						$(document).ready(function(){
							//Examples of how to assign the Colorbox event to elements			
							$(".group4").colorbox({rel:"group4", slideshow:true});
							$(".ajax").colorbox();
							$(".callbacks").colorbox({
								onOpen:function(){ alert("onOpen: colorbox is about to open"); },
								onLoad:function(){ alert("onLoad: colorbox has started to load the targeted content"); },
								onComplete:function(){ alert("onComplete: colorbox has displayed the loaded content"); },
								onCleanup:function(){ alert("onCleanup: colorbox has begun the close process"); },
								onClosed:function(){ alert("onClosed: colorbox has completely closed"); }
							});

							$(".non-retina").colorbox({rel:"group5", transition:"none"})
							$(".retina").colorbox({rel:"group5", transition:"none", retinaImage:true, retinaUrl:true});
							
							//Example of preserving a JavaScript event for inline calls.
							$("#click").click(function(){ 
								$("#click").css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
								return false;
							});
						});
					</script>
						<script type="text/javascript" src="jquery.js">
					</script>
					<script type="text/javascript">
						var htmlobjek;
						$(document).ready(function()
							{
							  //apabila terjadi event onchange terhadap object <select id=matakuliah>
							  $("#matakuliah").change(function()
								  {
									var matakuliah = $("#matakuliah").val();
									$.ajax({
										url: "ambil_group_praktikum.php",
										data: "matakuliah="+matakuliah,
										cache: false,
										success: function(msg)
											{
												//jika data sukses diambil dari server kita tampilkan
												//di <select id=groupPraktikum>
												$("#groupPraktikum").html(msg);
											}
										});
								  });
							});
					</script>			
				';
	}


function includeFooter()
{
	return '
			<!-- Le javascript
				================================================== -->
			<!-- Placed at the end of the document so the pages load faster -->
			  <script src="headmaster/js/jquery.min.js"></script>
			  <script src="headmaster/lib/jquery-ui/jquery-ui-1.8.23.custom.min.js"></script>
			  
            <!-- masked inputs -->
            <script src="headmaster/js/forms/jquery.inputmask.min.js"></script>
       
            <!-- datepicker -->
            <script src="headmaster/lib/datepicker/bootstrap-datepicker.min.js"></script
            
            <!-- timepicker -->
            <script src="headmaster/lib/datepicker/bootstrap-timepicker.min.js"></script>

			<!-- colorbox -->
			<script src="headmaster/lib/colorbox/jquery.colorbox.min.js"></script><!-- datatable -->
			<script src="headmaster/lib/datatables/jquery.dataTables.min.js"></script>
			<!-- additional sorting for datatables -->
			<script src="headmaster/lib/datatables/jquery.dataTables.sorting.js"></script>
			<!-- tables functions -->
			<script src="headmaster/js/gebo_tables.js"></script>
			<!-- form functions -->
            <script src="headmaster/js/gebo_forms.js"></script>
            
			<script>
				$(document).ready(function() {
					//* show all elements & remove preloader
					setTimeout("$("html").removeClass("js")",1000);
				});
				
				//* bootstrap datepicker
			
			</script>
			';
}

/////////////////menu//////////////////////////
	
function includeMenu()
	{
		return '
				<div class="row-fluid" >
				<div class="navbar navbar-fixed-top">
				<div class="navbar-inner">
					<div class="container">
						<ul class="nav nav-pills span12">
						'.cekMenu().'
						</ul>
					</div>
				</div>
				</div>
				</div>
				';
	}
	
/////////////////////////profile////////////////////////////
function includeProfile()
{
	return'
			<div class="span3" style="margin-bottom:10px; margin-left:0px">
				<div class="span12">
					<div class="span2">					
					</div>
					<div class="span8" >
						
					</div>
					<div class="span2">					
					</div>
				</div>
				<div class="spand12">						
						<ul class="thumbnails row-fluid"  style="margin-bottom: 0px;">
							<li class="span12 thumbnail"  style="min-height:100px;margin-bottom: 0px;margin-left:0px;" >					
								<!--<a href="carddisplay.php?id=112">-->
									<div align="center" class="" 
										style="text-align:center;font-size:9pt;padding: 3px 3px 0px;max-width:175px;margin-left:auto;margin-right:auto">							
											<img src="logo.png" width="304" height="228">
									</div>
								<!--</a>-->
							</li>
						</ul>
						<div style="margin:0px;align:center;font-size:15pt;margin-top:0px;margin-bottom:0px;padding-top: 4px; padding-bottom: 4px;" class="legend alert alert-info">
							<b>
							<!--ajax jam -->
								<div id="jam">
								</div>
							</b>
						</div>
				</div>
				<div class="spand12">
						<div style="margin:0px;align:center;font-size:15pt;margin-top:10px;margin-bottom:2px;padding-top: 4px; padding-bottom: 4px;" class="legend alert alert-info">
							<b>
								'.					
								includeCekProfileTitle()
								.'
							</b>
						</div>
						<ul class="thumbnails row-fluid"  style="margin-bottom: 0px;">
							<li class="span12 thumbnail"  style="min-height:100px;margin-bottom: 10px;margin-left:0px;" >					
								<!--<a href="carddisplay.php?id=112">-->
									<div align="center" class="" 
										style="text-align:center;font-size:12pt;padding: 3px 3px 0px;margin-left:auto;margin-right:auto">							
										'.includeCekProfilecontent().'
									</div>
								<!--</a>-->
							</li>
						</ul>
				</div>
			</div>
			';
}

// fungsi fungsi yang ada dalam menu ////////////////////////////////////////////////////////////////////////////////////////

function cekMenu()
	{
		$DATA='';
		if(isset($_SESSION['levelUser']))
			{
				if($_SESSION['levelUser']=="admin")
					{
						$DATA='
								<li'. setActiveMenu('mhs.php').'><a href="mhs.php"><i class="icon-home "></i>Mahasiswa</a></li>						
								<li'. setActiveMenu('pengajar.php').' ><a href="pengajar.php">Pengajar</a></li>
								<li'. setActiveMenu('mengajar.php').' ><a href="mengajar.php">Mengajar</a></li>
								<li'. setActiveMenu('asisten.php').' ><a href="asisten.php">Asisten</a></li>						
								<li'. setActiveMenu('mk.php').' ><a href="mk.php">Matakuliah</a></li>
								<li'. setActiveMenu('angket_kelas.php').' ><a href="angket_kelas.php">Angket kelas</a></li>
								<li'. setActiveMenu('angket_pengajar.php').' ><a href="angket_pengajar.php">Angket pengajar</a></li>						
								<li'. setActiveMenu('kelas.php').' ><a href="kelas.php">Kelas</a></li>
								<li'. setActiveMenu('detil_kelas.php').' ><a href="detil_kelas.php">Detil Kelas</a></li>
								<li'. setActiveMenu('minggu.php').' ><a href="minggu.php">Minggu</a></li>
								<li'. setActiveMenu('waktu_angket.php').' ><a href="waktu_angket.php">Waktu Angket</a></li>
							 ';
					}
				else if($_SESSION['levelUser']=="koordinator")
					{
						$DATA='
								<li'. setActiveMenu('unggah_modul.php').'><a href="unggah_modul.php"><i class="icon-home "></i>Unggah Modul</a></li>						
								<li'. setActiveMenu('unduh_modul.php').' ><a href="unduh_modul.php">Unduh Modul</a></li>
								<li'. setActiveMenu('unggah_tugas.php').' ><a href="unggah_tugas.php">Unggah Tugas</a></li>
								<li'. setActiveMenu('unduh_tugas.php').' ><a href="unduh_tugas.php">Unduh Tugas</a></li>
								<li'. setActiveMenu('unduh_jawaban_tugas.php').' ><a href="unduh_jawaban_tugas.php">Unduh Jawaban Tugas</a></li>
							 ';
					}
				else if($_SESSION['levelUser']=="pengajar")
					{
						$DATA='
								<li'. setActiveMenu('unduh_modul.php').' ><a href="unduh_modul.php">Unduh Modul</a></li>
								<li'. setActiveMenu('unduh_tugas.php').' ><a href="unduh_tugas.php">Unduh Tugas</a></li>
								<li'. setActiveMenu('unduh_jawaban_tugas.php').' ><a href="unduh_jawaban_tugas.php">Unduh Jawaban Tugas</a></li>
							 ';
					}
				else if($_SESSION['levelUser']=="praktikan")
					{
						$DATA='
								<li'. setActiveMenu('unduh_modul.php').' ><a href="unduh_modul.php">Unduh Modul</a></li>
								<li'. setActiveMenu('tugas_praktikan.php').' ><a href="tugas_praktikan.php">Tugas Praktikan</a></li>
								<li'. setActiveMenu('angket_praktikan.php').' ><a href="angket_praktikan.php">Angket Praktikan</a></li>
								<li'. setActiveMenu('jadwal_praktikan.php').' ><a href="jadwal_praktikan.php">Jadwal Praktikan</a></li>
							 ';
					}
			}
			else
			{
				$DATA='
						<li'. setActiveMenu('index.php').'><a href="index.php"><i class="icon-home "></i>Home</a></li>						
						<li'. setActiveMenu('about.php').' ><a href="about.php">About</a></li>
					  ';
				
			}
		RETURN $DATA;					
	}
		
//koding untuk mengsetmenu menjadi aktif
function setActiveMenu($pageName)
	{
		if(getCurrentPageName()==$pageName)
			{
				return ' class="active" ';
			}
		else
			{
				return '';
			}
	}

//koding untuk mencari nama file sekarang
function getCurrentPageName() 
	{
		return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
	}


////////////////////////////////////////fungsi fusngsi yang ada dalam menu    ////////////////////////////////////////////////

////// fungsi-fungsi yang ada dalam profile /////////////////////////////////////
function includeCekProfileTitle()
	{
		if(isset($_SESSION['levelUser']))
			{
				
				$profiletitle="Selamat Datang";
			}
		else
			{
				$profiletitle="Login";
			}
		return $profiletitle;
	}

function includeCekProfilecontent()
	{

		if(isset($_SESSION['levelUser']))
			{
				
				$profiletitle='
								<table >
										<tr>
												<td align="left"  valign="top">
													'.$_SESSION['levelUser'].' : 
												</td>
												<td>
													'.$_SESSION['NAMA'].' 
												</td>
										</tr>								
										<tr>
												<td>
													
												</td>
												<td align="left">
													<a href="logout.php">
														<button type="button" class="btn btn-small btn-primary">
															<i class="icon-off icon-white"></i>Logout
														</button>
													</a>
												</td>
										</tr>
									</table>				
								
								';
				
			}
		else
			{
				$profiletitle='<form action="proses_login.php" method="POST">		
									<table >
										<tr>
												<td align="left"  valign="top">
													Username 
												</td>
												<td>
													<input type="text" name="USERNAME" class="span12">
												</td>
										</tr>
										<tr>
												<td align="left" valign="top">
													Password
												</td>
												<td>
													<input type="password" name="PASSWORD" class="span12">
												</td>
										</tr>
										<tr>
												<td>
													
												</td>
												<td align="left">
													<button type="submit" class="btn btn-small btn-primary"><i class="icon-off icon-white"></i> Login</button></a>
												</td>
										</tr>
									</table>
								</form>	
								';
			}
		return $profiletitle;
			
	}
/// fungsi fungsi yang adal dalam profile /////////////////////////////////////////


//// templet tampilan update////////////////
function printPageUdate($content)
	{
		return '
					<html>
						<head>
						</head>
						<body>
							<div id="homer" style="  width:500px; padding:30px 10px;">
								'.$content.'
							</div>
						</body>
					</html>
				';
	}

//fungsi login

			
?>
